<?php
include_once '../meihe/common.php';
if ($islogin2 == 1) {
} else exit("<script language='javascript'>window.location.href='./login.php';</script>");
$title = '充值余额';
include_once './header.php';
?>
<style>
    .auth_color {
        background: linear-gradient(to left, #FF8A80, #FF5252);
        border-radius: 0.3rem;
        box-shadow: 1px 1px 9px 1px #eee;
    }

    .auth_color2 {
        background: linear-gradient(to left, #0091EA, #4FC3F7);
        border-radius: 0.3rem;
        box-shadow: 1px 1px 9px 1px #eee;
    }

    .auth_color3 {
        background: linear-gradient(to left, #5E35B1, #651FFF);
        border-radius: 0.3rem;
        box-shadow: 1px 1px 9px 1px #eee;
    }
</style>
<div class="row">
    <div class="col-lg-12">
        <div class="card">
            <div class="card-header">
                余额充值
            </div>
            <div class="card-body">
                <from class="layui-form">
                    <div class="text-center"><b>我当前的账户余额：<span style="font-size:16px; color:#FF6133;"><?php echo $userrow['rmb'] ?></span> 元</b></div>
                    <hr>
                    <input type="text" class="form-control" name="value" autocomplete="off" placeholder="输入要充值的余额" lay-verType="tips" lay-verify="required">
                    <br>
                    <div class="layui-row layui-col-space12 text-center">
                        <?php
                        if ($conf['alipay_api']) echo '<div class="layui-col-xs4"><button type="submit" class="layui-btn layui-btn-fluid auth_color3" lay-submit lay-filter="buy_alipay">支付宝</button></div>';
                        if ($conf['qqpay_api']) echo '<div class="layui-col-xs4"><button type="submit" class="layui-btn layui-btn-fluid auth_color2" lay-submit lay-filter="buy_qqpay">QQ钱包</button></div>';
                        if ($conf['wxpay_api']) echo '<div class="layui-col-xs4"><button type="submit" class="layui-btn layui-btn-fluid auth_color" lay-submit lay-filter="buy_wxpay">微信支付</button></div>';
                        ?>
                    </div>
                    </form>
                    <hr>
                    <div class="text-center"><small style="color:red;">提示：最低充值金额<?php echo $conf['recharge_min'] ?? 0 ?>元，最高充值金额<?php echo $conf['recharge_max'] ?? 0 ?>元</small></div>
            </div>
        </div>
    </div>
</div>
<?php
include_once './bottom.php';
?>
<script type="text/javascript">
    layui.use(['form', 'element'], function() {
        var form = layui.form;
        var element = layui.element;
        form.on('submit(buy_alipay)', function(data) {
            dopay('alipay');
            return false;
        });
        form.on('submit(buy_qqpay)', function(data) {
            dopay('qqpay');
            return false;
        });
        form.on('submit(buy_wxpay)', function(data) {
            dopay('wxpay');
            return false;
        });
        form.on('submit(usekm)', function(data) {
            usekm();
            return false;
        });
    });

    function dopay(type) {
        var value = $("input[name='value']").val();
        if (value == '' || value == 0) {
            layer.msg('充值金额不能为空', {
                icon: 5
            });
            return false;
        }
        $.get("ajax.php?act=recharge&type=" + type + "&value=" + value, function(data) {
            if (data.code == 0) {
                window.location.href = '../hhpay/submit.php?type=' + type + '&orderid=' + data.trade_no;
            } else {
                layer.msg(data.msg, {
                    icon: 5
                });
            }
        }, 'json');
    }
</script>